In [ ]:
import pyowm # Open Weather Map
from datetime import datetime
from dateutil.tz import tz, tzlocal
import calendar
owm = pyowm.OWM('Deleted')
In [ ]:
Sedona_id = 5313667
PHX_id = 5308655
GC_id = 5296391
YOS_id = 5410943
LAX_id = 3882428
PAS_id = 4364990
Sedona = owm.weather_at_id(Sedona_id)
PHX = owm.weather_at_id(PHX_id)
GC = owm.weather_at_id(GC_id)
PHX_fc = owm.daily_forecast('Phoenix', limit=7)
SED_fc = owm.daily_forecast('Sedona', limit=7)
GC_fc = owm.daily_forecast('Grand Canyon', limit=7)
LAX_fc = owm.daily_forecast('Los Angeles', limit=7)
YOS_fc = owm.daily_forecast('El Portal', limit=7)
print(SED_fc)
print(GC_fc)
print(LAX_fc)
forecast = LAX_fc.get_forecast()
for w in forecast:
print((calendar.day_name[w.get_reference_time(timeformat='date').weekday()]))
print(w.get_temperature('fahrenheit'))
In [ ]:
LAX_fc = owm.daily_forecast('Los Angeles', limit=7)
YOS_fc = owm.daily_forecast('El Portal', limit=7)
forecast = YOS_fc.get_forecast()
YOS_day = ['Wednesday', 'Thursday', 'Friday']
LAX_day = ['Saturday', 'Sunday', 'Friday']
for y in forecast:
day = (calendar.day_name[y.get_reference_time(timeformat='date').weekday()])
if day in YOS_day:
print(day, 'In Yosemite')
print(y.get_temperature('fahrenheit'))
forecast = LAX_fc.get_forecast()
for z in forecast:
day = (calendar.day_name[z.get_reference_time(timeformat='date').weekday()])
if day in LAX_day:
print(day, ' in Pasadena')
print(z.get_temperature('fahrenheit'))
print(forecast)
In [ ]:
Thur = {'morn':0,'day':0,'eve':0,'night':0}
Fri = {'morn':0,'day':0,'eve':0,'night':0}
Sat = {'morn':0,'day':0,'eve':0,'night':0}
Sun = {'morn':0,'day':0,'eve':0,'night':0}
Mon = {'morn':0,'day':0,'eve':0,'night':0}
print(Sun)
forecast = PHX_fc.get_forecast()
for w in forecast:
day = (calendar.day_name[w.get_reference_time(timeformat='date').weekday()])
temp = w.get_temperature('fahrenheit')
if (day == 'Thursday'):
Thur['morn'] = 'x'
Thur['day'] = temp['day']
print('Phoenix on Thursday: (high)', temp['max'], '(low)', temp['min'])
if (day == 'Sunday'):
Sun['eve'] = temp['eve']
Sun['night'] = temp['night']
print('Phoenix on Sunday: (high)', temp['max'], '(low)', temp['min'])
if (day == 'Monday'):
Mon['morn'] = temp['morn']
Mon['day'] = temp['day']
Mon['eve'] = 'x'
Mon['night'] = 'x'
print('Phoenix on Monday: (high)', temp['max'], '(low)', temp['min'], w.get_reference_time(timeformat='date'))
forecast = SED_fc.get_forecast()
for w in forecast:
day = (calendar.day_name[w.get_reference_time(timeformat='date').weekday()])
temp = w.get_temperature('fahrenheit')
if (day == 'Thursday'):
Thur['eve'] = temp['eve']
Thur['night'] = temp['night']
print('Sedona on Thursday: (high)', temp['max'], '(low)', temp['min'])
if (day == 'Friday'):
Fri['morn'] = temp['morn']
Fri['day'] = temp['day']
print('Sedona on Friday: (high)', temp['max'], '(low)', temp['min'])
forecast = GC_fc.get_forecast()
for w in forecast:
day = (calendar.day_name[w.get_reference_time(timeformat='date').weekday()])
temp = w.get_temperature('fahrenheit')
if (day == 'Friday'):
Fri['eve'] = temp['eve']
Fri['night'] = temp['night']
print('Grand Canyon on Friday: (high)', temp['max'], '(low)', temp['min'])
print('snow: ', w.get_snow())
if (day == 'Saturday'):
Sat['morn'] = temp['morn']
Sat['day'] = temp['day']
Sat['eve'] = temp['eve']
Sat['night'] = temp['night']
print('Grand Canyon on Saturday: (high)', temp['max'], '(low)', temp['min'])
print('snow: ', w.get_snow())
if (day == 'Sunday'):
Sun['morn'] = temp['morn']
Sun['day'] = temp['day']
print('Grand Canyon on Sunday: (high)', temp['max'], '(low)', temp['min'])
print('snow: ', w.get_snow())
In [ ]:
print('Thursday Phoenix (day) - Arrive at Noon ', Thur['day'])
print('Thursday Sedona (night) - Check in around 3 ', Thur['night'])
print('Friday Sedona (morning to day) ', Fri['morn'], 'to', Fri['day'])
print('Friday Grand Canyon (evening to night) ', Fri['eve'], 'to', Fri['night'])
print('Saturday Grand Canyon (all day) ', Sat['morn'], 'to', Sat['day'], Sat['eve'], 'to', Sat['night'])
print('Sunday Grand Canyon (morning to day)', Sun['morn'], 'to', Sun['day'])
print('Sunday Phoenix (evening to night) ', Sun['eve'], 'to', Sun['night'])
print('Monday Phoneix (morning to day) - flight at 5pm ', Mon['morn'], 'to', Mon['day'])
In [ ]:
forecast = PHX_fc.get_forecast()
print(forecast.get_location().get_name())
for w in forecast:
print(w.get_temperature('fahrenheit'))
print(w.get_snow())
theDate = w.get_reference_time(timeformat='date'))
print(theDate)
In [ ]: